<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<P>
<H2>visits:</H2>
<script type="text/javascript">
// use the loading message for DWR
    dwr.util.useLoadingMessage();
    


function parseYmdDate(dateStr) {
	var dateParts = dateStr.split('-');
	var theDate = new Date();
	theDate.setYear(dateParts[0]);
	theDate.setMonth(dateParts[1]);
	theDate.setDate(dateParts[2]);
	return theDate;
}
    
function searchVisits() {
 var startDateStr = dwr.util.byId('startDate').value;
 var endDateStr = dwr.util.byId('endDate').value;
 dwr.util.removeAllRows('visitTableBody');
 DwrClinic.findVisits(parseYmdDate(startDateStr),parseYmdDate(endDateStr), function(visits) {
	var rowCreator =[
	function(visit) {return visit.date},
	function(visit) {return visit.vet.displayableName},
	function(visit) {return visit.pet.owner.displayableName},
	function(visit) {return visit.pet.name},
	function(visit) {return visit.description}
		];
	
	dwr.util.addRows('visitTableBody',visits, rowCreator);  
 });
}
</script>
<form onsubmit="searchVisits();return false;">
<input type="text" id="startDate" name="startDate"/>
<input type="text" id="endDate" name="endDate"/>
<script type="text/javascript">
// set up the calendars
    Calendar.setup({
        inputField     :    "startDate",      // id of the input field
//        ifFormat       :    "%Y-%m-%d %H:%M",       // format of the input field
        ifFormat       :    "%Y-%m-%d",       // format of the input field
        showsTime      :    false,            // will display a time selector
        timeFormat     :    "24"
    });
    Calendar.setup({
        inputField     :    "endDate",      // id of the input field
//        ifFormat       :    "%Y-%m-%d %H:%M",       // format of the input field
        ifFormat       :    "%Y-%m-%d",       // format of the input field
        showsTime      :    false,            // will display a time selector
        timeFormat     :    "24"
    });
</script>    

 <a href="javascript:searchVisits()">Search</a>
</form>
<TABLE border="1" id="visitTable">
<thead>
<tr>
  <TH>Date</TH>
  <TH>Vet</TH>
  <TH>Owner</TH>
  <TH>Pet</TH>
  <TH>Description</TH>
  </tr>
  </thead>
  <tbody id="visitTableBody"></tbody>
</TABLE>

<P>
<BR>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
